#include "gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkwidgetprivate.h"
-
+#include "gtkstylecontextprivate.h"
/**
* SECTION:gtkentry
}
else /* overwrite_mode */
{
+ GtkStyleContext *context;
GdkRGBA cursor_color;
GdkRectangle rect;
gint x, y;
rect.width = PANGO_PIXELS (cursor_rect.width);
rect.height = PANGO_PIXELS (cursor_rect.height);
- _gtk_widget_get_cursor_color (widget, &cursor_color);
+ context = gtk_widget_get_style_context (widget);
+
+ _gtk_style_context_get_cursor_color (context, &cursor_color, NULL);
gdk_cairo_set_source_rgba (cr, &cursor_color);
gdk_cairo_rectangle (cr, &rect);
cairo_fill (cr);
if (!block_at_line_end)
{
- GtkStyleContext *context;
GtkStateFlags state;
GdkRGBA color;
- context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_background_color (context, state, &color);
#include "gtkspinner.h"
#include "gtkborder.h"
-
/**
* SECTION:gtkstyle
* @Short_description: An object that hold style information for widgets
cairo_restore (cr);
}
-static void
-get_cursor_color (GtkStyleContext *context,
- gboolean primary,
- GdkRGBA *color)
-{
- GdkColor *style_color;
-
- gtk_style_context_get_style (context,
- primary ? "cursor-color" : "secondary-cursor-color",
- &style_color,
- NULL);
-
- if (style_color)
- {
- color->red = style_color->red / 65535;
- color->green = style_color->green / 65535;
- color->blue = style_color->blue / 65535;
- color->alpha = 1;
-
- gdk_color_free (style_color);
- }
- else
- {
- gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, color);
-
- if (!primary)
- {
- GdkRGBA bg;
-
- gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg);
-
- color->red = (color->red + bg.red) * 0.5;
- color->green = (color->green + bg.green) * 0.5;
- color->blue = (color->blue + bg.blue) * 0.5;
- }
- }
-}
-
-void
-_gtk_widget_get_cursor_color (GtkWidget *widget,
- GdkRGBA *color)
-{
- GtkStyleContext *context;
-
- context = gtk_widget_get_style_context (widget);
-
- get_cursor_color (context, TRUE, color);
-}
-
/**
* gtk_draw_insertion_cursor:
* @widget: a #GtkWidget
gfloat cursor_aspect_ratio;
gint offset;
GtkStyleContext *context;
- GdkRGBA color;
+ GdkRGBA primary_color;
+ GdkRGBA secondary_color;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (cr != NULL);
context = gtk_widget_get_style_context (widget);
- get_cursor_color (context, is_primary, &color);
- gdk_cairo_set_source_rgba (cr, &color);
+ _gtk_style_context_get_cursor_color (context, &primary_color, &secondary_color);
+ gdk_cairo_set_source_rgba (cr, is_primary ? &primary_color : &secondary_color);
/* When changing the shape or size of the cursor here,
* propagate the changes to gtktextview.c:text_window_invalidate_cursors().
return NULL;
}
+static void
+get_cursor_color (GtkStyleContext *context,
+ gboolean primary,
+ GdkRGBA *color)
+{
+ GdkColor *style_color;
+
+ gtk_style_context_get_style (context,
+ primary ? "cursor-color" : "secondary-cursor-color",
+ &style_color,
+ NULL);
+
+ if (style_color)
+ {
+ color->red = style_color->red / 65535;
+ color->green = style_color->green / 65535;
+ color->blue = style_color->blue / 65535;
+ color->alpha = 1;
+
+ gdk_color_free (style_color);
+ }
+ else
+ {
+ gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, color);
+
+ if (!primary)
+ {
+ GdkRGBA bg;
+
+ gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg);
+
+ color->red = (color->red + bg.red) * 0.5;
+ color->green = (color->green + bg.green) * 0.5;
+ color->blue = (color->blue + bg.blue) * 0.5;
+ }
+ }
+}
+
+void
+_gtk_style_context_get_cursor_color (GtkStyleContext *context,
+ GdkRGBA *primary_color,
+ GdkRGBA *secondary_color)
+{
+ if (primary_color)
+ get_cursor_color (context, TRUE, primary_color);
+
+ if (secondary_color)
+ get_cursor_color (context, FALSE, secondary_color);
+}
+
/* Paint methods */
/**
GtkWidget *widget);
gboolean _gtk_style_context_check_region_name (const gchar *str);
+void _gtk_style_context_get_cursor_color (GtkStyleContext *context,
+ GdkRGBA *primary_color,
+ GdkRGBA *secondary_color);
G_END_DECLS
#include "config.h"
#include "gtktextdisplay.h"
#include "gtkwidgetprivate.h"
+#include "gtkstylecontextprivate.h"
#include "gtkintl.h"
/* DO NOT go putting private headers in here. This file should only
GdkRGBA cursor_color;
cairo_t *cr = text_renderer->cr;
- /* we draw text using base color on filled cursor rectangle of cursor color
- * (normally white on black) */
- _gtk_widget_get_cursor_color (text_renderer->widget, &cursor_color);
+ /* we draw text using base color on filled cursor rectangle of cursor color
+ * (normally white on black) */
+ _gtk_style_context_get_cursor_color (context, &cursor_color, NULL);
cursor_rect.x = x + line_display->x_offset + line_display->block_cursor.x;
cursor_rect.y = y + line_display->block_cursor.y + line_display->top_margin;
int *x,
int *y);
-void _gtk_widget_get_cursor_color (GtkWidget *widget,
- GdkRGBA *color);
-
G_END_DECLS
#endif /* __GTK_WIDGET_PRIVATE_H__ */